<template>
  <a-spin :spinning="confirmLoading">
    <JFormContainer :disabled="disabled">
      <template #detail>
        <a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="SlopeStableSettingForm">
          <a-row>
						<a-col :span="24">
							<a-form-item label="切坡高度权重" v-bind="validateInfos.cutSlopeHeightWeight" id="SlopeStableSettingForm-cutSlopeHeightWeight" name="cutSlopeHeightWeight">
								<a-input-number v-model:value="formData.cutSlopeHeightWeight" placeholder="请输入切坡高度权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡高度 H≤5m" v-bind="validateInfos.cutSlopeHeight1" id="SlopeStableSettingForm-cutSlopeHeight1" name="cutSlopeHeight1">
								<a-input-number v-model:value="formData.cutSlopeHeight1" placeholder="请输入切坡高度 H≤5m" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡高度 5m＜H≤10m" v-bind="validateInfos.cutSlopeHeight2" id="SlopeStableSettingForm-cutSlopeHeight2" name="cutSlopeHeight2">
								<a-input-number v-model:value="formData.cutSlopeHeight2" placeholder="请输入切坡高度 5m＜H≤10m" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡高度 10m＜H≤15m" v-bind="validateInfos.cutSlopeHeight3" id="SlopeStableSettingForm-cutSlopeHeight3" name="cutSlopeHeight3">
								<a-input-number v-model:value="formData.cutSlopeHeight3" placeholder="请输入切坡高度 10m＜H≤15m" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡高度 H＞15m" v-bind="validateInfos.cutSlopeHeight4" id="SlopeStableSettingForm-cutSlopeHeight4" name="cutSlopeHeight4">
								<a-input-number v-model:value="formData.cutSlopeHeight4" placeholder="请输入切坡高度 H＞15m" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡度权重" v-bind="validateInfos.cutSlopeGradientWeight" id="SlopeStableSettingForm-cutSlopeGradientWeight" name="cutSlopeGradientWeight">
								<a-input-number v-model:value="formData.cutSlopeGradientWeight" placeholder="请输入切坡坡度权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡度 a≤45°" v-bind="validateInfos.cutSlopeGradient1" id="SlopeStableSettingForm-cutSlopeGradient1" name="cutSlopeGradient1">
								<a-input-number v-model:value="formData.cutSlopeGradient1" placeholder="请输入切坡坡度 a≤45°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡度 45°＜a≤60°" v-bind="validateInfos.cutSlopeGradient2" id="SlopeStableSettingForm-cutSlopeGradient2" name="cutSlopeGradient2">
								<a-input-number v-model:value="formData.cutSlopeGradient2" placeholder="请输入切坡坡度 45°＜a≤60°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡度 60°＜a≤75°" v-bind="validateInfos.cutSlopeGradient3" id="SlopeStableSettingForm-cutSlopeGradient3" name="cutSlopeGradient3">
								<a-input-number v-model:value="formData.cutSlopeGradient3" placeholder="请输入切坡坡度 60°＜a≤75°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡度 ＞75°" v-bind="validateInfos.cutSlopeGradient4" id="SlopeStableSettingForm-cutSlopeGradient4" name="cutSlopeGradient4">
								<a-input-number v-model:value="formData.cutSlopeGradient4" placeholder="请输入切坡坡度 ＞75°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡形权重" v-bind="validateInfos.cutSlopeShapeWeight" id="SlopeStableSettingForm-cutSlopeShapeWeight" name="cutSlopeShapeWeight">
								<a-input-number v-model:value="formData.cutSlopeShapeWeight" placeholder="请输入切坡坡形权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡形 阶梯型" v-bind="validateInfos.cutSlopeShape1" id="SlopeStableSettingForm-cutSlopeShape1" name="cutSlopeShape1">
								<a-input-number v-model:value="formData.cutSlopeShape1" placeholder="请输入切坡坡形 阶梯型" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡形 内凹型" v-bind="validateInfos.cutSlopeShape2" id="SlopeStableSettingForm-cutSlopeShape2" name="cutSlopeShape2">
								<a-input-number v-model:value="formData.cutSlopeShape2" placeholder="请输入切坡坡形 内凹型" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡形 直线型" v-bind="validateInfos.cutSlopeShape3" id="SlopeStableSettingForm-cutSlopeShape3" name="cutSlopeShape3">
								<a-input-number v-model:value="formData.cutSlopeShape3" placeholder="请输入切坡坡形 直线型" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="切坡坡形 外凸型" v-bind="validateInfos.cutSlopeShape4" id="SlopeStableSettingForm-cutSlopeShape4" name="cutSlopeShape4">
								<a-input-number v-model:value="formData.cutSlopeShape4" placeholder="请输入切坡坡形 外凸型" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="自然斜坡坡度权重" v-bind="validateInfos.naturalSlopeGradientWeight" id="SlopeStableSettingForm-naturalSlopeGradientWeight" name="naturalSlopeGradientWeight">
								<a-input-number v-model:value="formData.naturalSlopeGradientWeight" placeholder="请输入自然斜坡坡度权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="自然斜坡坡度 b≤20°" v-bind="validateInfos.naturalSlopeGradient1" id="SlopeStableSettingForm-naturalSlopeGradient1" name="naturalSlopeGradient1">
								<a-input-number v-model:value="formData.naturalSlopeGradient1" placeholder="请输入自然斜坡坡度 b≤20°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="自然斜坡坡度 20°＜b≤30°" v-bind="validateInfos.naturalSlopeGradient2" id="SlopeStableSettingForm-naturalSlopeGradient2" name="naturalSlopeGradient2">
								<a-input-number v-model:value="formData.naturalSlopeGradient2" placeholder="请输入自然斜坡坡度 20°＜b≤30°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="自然斜坡坡度 ＞30°" v-bind="validateInfos.naturalSlopeGradient3" id="SlopeStableSettingForm-naturalSlopeGradient3" name="naturalSlopeGradient3">
								<a-input-number v-model:value="formData.naturalSlopeGradient3" placeholder="请输入自然斜坡坡度 ＞30°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土层松散程度权重" v-bind="validateInfos.soilLoosenessWeight" id="SlopeStableSettingForm-soilLoosenessWeight" name="soilLoosenessWeight">
								<a-input-number v-model:value="formData.soilLoosenessWeight" placeholder="请输入土层松散程度权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土层松散程度 密实" v-bind="validateInfos.soilLooseness1" id="SlopeStableSettingForm-soilLooseness1" name="soilLooseness1">
								<a-input-number v-model:value="formData.soilLooseness1" placeholder="请输入土层松散程度 密实" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土层松散程度 松散" v-bind="validateInfos.soilLooseness2" id="SlopeStableSettingForm-soilLooseness2" name="soilLooseness2">
								<a-input-number v-model:value="formData.soilLooseness2" placeholder="请输入土层松散程度 松散" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土体类型权重" v-bind="validateInfos.overlyingSoilTypeWeight" id="SlopeStableSettingForm-overlyingSoilTypeWeight" name="overlyingSoilTypeWeight">
								<a-input-number v-model:value="formData.overlyingSoilTypeWeight" placeholder="请输入土体类型权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土体类型 粘性土" v-bind="validateInfos.overlyingSoilType1" id="SlopeStableSettingForm-overlyingSoilType1" name="overlyingSoilType1">
								<a-input-number v-model:value="formData.overlyingSoilType1" placeholder="请输入土体类型 粘性土" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土体类型 砂质土" v-bind="validateInfos.overlyingSoilType2" id="SlopeStableSettingForm-overlyingSoilType2" name="overlyingSoilType2">
								<a-input-number v-model:value="formData.overlyingSoilType2" placeholder="请输入土体类型 砂质土" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="土体类型 碎石土" v-bind="validateInfos.overlyingSoilType3" id="SlopeStableSettingForm-overlyingSoilType3" name="overlyingSoilType3">
								<a-input-number v-model:value="formData.overlyingSoilType3" placeholder="请输入土体类型 碎石土" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型权重" v-bind="validateInfos.rockTypeWeight" id="SlopeStableSettingForm-rockTypeWeight" name="rockTypeWeight">
								<a-input-number v-model:value="formData.rockTypeWeight" placeholder="请输入岩组类型权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 坚硬的块状侵入岩岩组(Y1)" v-bind="validateInfos.rockType1" id="SlopeStableSettingForm-rockType1" name="rockType1">
								<a-input-number v-model:value="formData.rockType1" placeholder="请输入岩组类型 坚硬的块状侵入岩岩组(Y1)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的块状火山熔岩，火山碎屑熔岩夹中厚—厚层状火山碎屑岩岩组(Y2)" v-bind="validateInfos.rockType2" id="SlopeStableSettingForm-rockType2" name="rockType2">
								<a-input-number v-model:value="formData.rockType2" placeholder="请输入岩组类型 较坚硬、坚硬的块状火山熔岩，火山碎屑熔岩夹中厚—厚层状火山碎屑岩岩组(Y2)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的薄-厚层状板岩、变碎屑岩、千枚岩岩组(B3)" v-bind="validateInfos.rockType3" id="SlopeStableSettingForm-rockType3" name="rockType3">
								<a-input-number v-model:value="formData.rockType3" placeholder="请输入岩组类型 较坚硬、坚硬的薄-厚层状板岩、变碎屑岩、千枚岩岩组(B3)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的片状片岩岩组(B2)" v-bind="validateInfos.rockType4" id="SlopeStableSettingForm-rockType4" name="rockType4">
								<a-input-number v-model:value="formData.rockType4" placeholder="请输入岩组类型 较坚硬、坚硬的片状片岩岩组(B2)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的块状变粒岩组(B1)" v-bind="validateInfos.rockType5" id="SlopeStableSettingForm-rockType5" name="rockType5">
								<a-input-number v-model:value="formData.rockType5" placeholder="请输入岩组类型 较坚硬、坚硬的块状变粒岩组(B1)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 软硬相间的薄—厚层状含煤砂岩、页岩、泥岩岩组(S3)" v-bind="validateInfos.rockType6" id="SlopeStableSettingForm-rockType6" name="rockType6">
								<a-input-number v-model:value="formData.rockType6" placeholder="请输入岩组类型 软硬相间的薄—厚层状含煤砂岩、页岩、泥岩岩组(S3)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 软弱的、较坚硬的薄—厚层状红层砂岩、砂砾岩、泥岩岩组(S4)" v-bind="validateInfos.rockType7" id="SlopeStableSettingForm-rockType7" name="rockType7">
								<a-input-number v-model:value="formData.rockType7" placeholder="请输入岩组类型 软弱的、较坚硬的薄—厚层状红层砂岩、砂砾岩、泥岩岩组(S4)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的薄—厚层状泥岩、页岩、硅质岩岩组(S1)" v-bind="validateInfos.rockType8" id="SlopeStableSettingForm-rockType8" name="rockType8">
								<a-input-number v-model:value="formData.rockType8" placeholder="请输入岩组类型 较坚硬、坚硬的薄—厚层状泥岩、页岩、硅质岩岩组(S1)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的中厚—厚层状砂岩、砂砾岩、页岩岩组(S2)" v-bind="validateInfos.rockType9" id="SlopeStableSettingForm-rockType9" name="rockType9">
								<a-input-number v-model:value="formData.rockType9" placeholder="请输入岩组类型 较坚硬、坚硬的中厚—厚层状砂岩、砂砾岩、页岩岩组(S2)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 软弱的、较坚硬的薄层状页岩、砂岩、硅质岩岩组(S5)" v-bind="validateInfos.rockType10" id="SlopeStableSettingForm-rockType10" name="rockType10">
								<a-input-number v-model:value="formData.rockType10" placeholder="请输入岩组类型 软弱的、较坚硬的薄层状页岩、砂岩、硅质岩岩组(S5)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的薄—厚层状弱岩溶化杂质灰岩、砂岩、页岩岩组(T3)" v-bind="validateInfos.rockType11" id="SlopeStableSettingForm-rockType11" name="rockType11">
								<a-input-number v-model:value="formData.rockType11" placeholder="请输入岩组类型 较坚硬、坚硬的薄—厚层状弱岩溶化杂质灰岩、砂岩、页岩岩组(T3)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 较坚硬、坚硬的薄-厚层状中等岩溶化灰岩、白云质灰岩、页岩岩组(T2)" v-bind="validateInfos.rockType12" id="SlopeStableSettingForm-rockType12" name="rockType12">
								<a-input-number v-model:value="formData.rockType12" placeholder="请输入岩组类型 较坚硬、坚硬的薄-厚层状中等岩溶化灰岩、白云质灰岩、页岩岩组(T2)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="岩组类型 坚硬的中厚-厚层状中等-强岩溶化灰岩、白云岩岩组(T1)" v-bind="validateInfos.rockType13" id="SlopeStableSettingForm-rockType13" name="rockType13">
								<a-input-number v-model:value="formData.rockType13" placeholder="请输入岩组类型 坚硬的中厚-厚层状中等-强岩溶化灰岩、白云岩岩组(T1)" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="植被覆盖率权重" v-bind="validateInfos.vegetationCoverageWeight" id="SlopeStableSettingForm-vegetationCoverageWeight" name="vegetationCoverageWeight">
								<a-input-number v-model:value="formData.vegetationCoverageWeight" placeholder="请输入植被覆盖率权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="植被覆盖率 b≤20°" v-bind="validateInfos.vegetationCoverage1" id="SlopeStableSettingForm-vegetationCoverage1" name="vegetationCoverage1">
								<a-input-number v-model:value="formData.vegetationCoverage1" placeholder="请输入植被覆盖率 b≤20°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="植被覆盖率 20°＜b≤80°" v-bind="validateInfos.vegetationCoverage2" id="SlopeStableSettingForm-vegetationCoverage2" name="vegetationCoverage2">
								<a-input-number v-model:value="formData.vegetationCoverage2" placeholder="请输入植被覆盖率 20°＜b≤80°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="植被覆盖率 ＞80°" v-bind="validateInfos.vegetationCoverage3" id="SlopeStableSettingForm-vegetationCoverage3" name="vegetationCoverage3">
								<a-input-number v-model:value="formData.vegetationCoverage3" placeholder="请输入植被覆盖率 ＞80°" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="已有治理措施权重" v-bind="validateInfos.governanceMeasuresWeight" id="SlopeStableSettingForm-governanceMeasuresWeight" name="governanceMeasuresWeight">
								<a-input-number v-model:value="formData.governanceMeasuresWeight" placeholder="请输入已有治理措施权重" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="已有治理措施 截排水沟" v-bind="validateInfos.governanceMeasures1" id="SlopeStableSettingForm-governanceMeasures1" name="governanceMeasures1">
								<a-input-number v-model:value="formData.governanceMeasures1" placeholder="请输入已有治理措施 截排水沟" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="已有治理措施 护脚墙" v-bind="validateInfos.governanceMeasures2" id="SlopeStableSettingForm-governanceMeasures2" name="governanceMeasures2">
								<a-input-number v-model:value="formData.governanceMeasures2" placeholder="请输入已有治理措施 护脚墙" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="已有治理措施 挡土墙" v-bind="validateInfos.governanceMeasures3" id="SlopeStableSettingForm-governanceMeasures3" name="governanceMeasures3">
								<a-input-number v-model:value="formData.governanceMeasures3" placeholder="请输入已有治理措施 挡土墙" style="width: 100%" />
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="已有治理措施 综合治理" v-bind="validateInfos.governanceMeasures4" id="SlopeStableSettingForm-governanceMeasures4" name="governanceMeasures4">
								<a-input-number v-model:value="formData.governanceMeasures4" placeholder="请输入已有治理措施 综合治理" style="width: 100%" />
							</a-form-item>
						</a-col>
          </a-row>
        </a-form>
      </template>
    </JFormContainer>
  </a-spin>
</template>

<script lang="ts" setup>
  import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
  import { defHttp } from '/@/utils/http/axios';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { getValueType } from '/@/utils';
  import { saveOrUpdate } from '../SlopeStableSetting.api';
  import { Form } from 'ant-design-vue';
  import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  const props = defineProps({
    formDisabled: { type: Boolean, default: false },
    formData: { type: Object, default: () => ({})},
    formBpm: { type: Boolean, default: true }
  });
  const formRef = ref();
  const useForm = Form.useForm;
  const emit = defineEmits(['register', 'ok']);
  const formData = reactive<Record<string, any>>({
    id: '',
    cutSlopeHeightWeight: undefined,
    cutSlopeHeight1: undefined,
    cutSlopeHeight2: undefined,
    cutSlopeHeight3: undefined,
    cutSlopeHeight4: undefined,
    cutSlopeGradientWeight: undefined,
    cutSlopeGradient1: undefined,
    cutSlopeGradient2: undefined,
    cutSlopeGradient3: undefined,
    cutSlopeGradient4: undefined,
    cutSlopeShapeWeight: undefined,
    cutSlopeShape1: undefined,
    cutSlopeShape2: undefined,
    cutSlopeShape3: undefined,
    cutSlopeShape4: undefined,
    naturalSlopeGradientWeight: undefined,
    naturalSlopeGradient1: undefined,
    naturalSlopeGradient2: undefined,
    naturalSlopeGradient3: undefined,
    soilLoosenessWeight: undefined,
    soilLooseness1: undefined,
    soilLooseness2: undefined,
    overlyingSoilTypeWeight: undefined,
    overlyingSoilType1: undefined,
    overlyingSoilType2: undefined,
    overlyingSoilType3: undefined,
    rockTypeWeight: undefined,
    rockType1: undefined,
    rockType2: undefined,
    rockType3: undefined,
    rockType4: undefined,
    rockType5: undefined,
    rockType6: undefined,
    rockType7: undefined,
    rockType8: undefined,
    rockType9: undefined,
    rockType10: undefined,
    rockType11: undefined,
    rockType12: undefined,
    rockType13: undefined,
    vegetationCoverageWeight: undefined,
    vegetationCoverage1: undefined,
    vegetationCoverage2: undefined,
    vegetationCoverage3: undefined,
    governanceMeasuresWeight: undefined,
    governanceMeasures1: undefined,
    governanceMeasures2: undefined,
    governanceMeasures3: undefined,
    governanceMeasures4: undefined,
  });
  const { createMessage } = useMessage();
  const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
  const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
  const confirmLoading = ref<boolean>(false);
  //表单验证
  const validatorRules = reactive({
  });
  const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });

  // 表单禁用
  const disabled = computed(()=>{
    if(props.formBpm === true){
      if(props.formData.disabled === false){
        return false;
      }else{
        return true;
      }
    }
    return props.formDisabled;
  });

  
  /**
   * 新增
   */
  function add() {
    edit({});
  }

  /**
   * 编辑
   */
  function edit(record) {
    nextTick(() => {
      resetFields();
      const tmpData = {};
      Object.keys(formData).forEach((key) => {
        if(record.hasOwnProperty(key)){
          tmpData[key] = record[key]
        }
      })
      //赋值
      Object.assign(formData, tmpData);
    });
  }

  /**
   * 提交数据
   */
  async function submitForm() {
    try {
      // 触发表单验证
      await validate();
    } catch ({ errorFields }) {
      if (errorFields) {
        const firstField = errorFields[0];
        if (firstField) {
          formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
        }
      }
      return Promise.reject(errorFields);
    }
    confirmLoading.value = true;
    const isUpdate = ref<boolean>(false);
    //时间格式化
    let model = formData;
    if (model.id) {
      isUpdate.value = true;
    }
    //循环数据
    for (let data in model) {
      //如果该数据是数组并且是字符串类型
      if (model[data] instanceof Array) {
        let valueType = getValueType(formRef.value.getProps, data);
        //如果是字符串类型的需要变成以逗号分割的字符串
        if (valueType === 'string') {
          model[data] = model[data].join(',');
        }
      }
    }
    await saveOrUpdate(model, isUpdate.value)
      .then((res) => {
        if (res.success) {
          createMessage.success(res.message);
          emit('ok');
        } else {
          createMessage.warning(res.message);
        }
      })
      .finally(() => {
        confirmLoading.value = false;
      });
  }


  defineExpose({
    add,
    edit,
    submitForm,
  });
</script>

<style lang="less" scoped>
  .antd-modal-form {
    padding: 14px;
  }
</style>
